package com.yanjr.modules.cms.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.yanjr.common.persistence.BaseDaoImpl;
import com.yanjr.common.utils.DateUtil;
import com.yanjr.common.utils.StringUtils;
import com.yanjr.modules.cms.dao.LinkDao;
import com.yanjr.modules.cms.entity.Link;

@Repository("linkDao")
public class LinkDaoImpl extends BaseDaoImpl<Link> implements LinkDao {

	@Override
	public List<Link> findByIdIn(String[] ids) {
		String sql = "select * from cms_link where id in ('" + StringUtils.join(ids, "','") + "')";
		return super.findList(sql);
	}

	@Override
	public int updateExpiredWeight() {
		String sql = "update cms_link set weight=0 where weight>0 and weight_date<?";
		return super.update(sql, DateUtil.getDateTime());
	}

}
